package exam.huawei;

import java.util.Scanner;

/**
 * @author chenhong
 * @version 1.0
 * @description TODO
 * @date 2023/4/8 13:59
 */
public class HJ2 {
}
class Main2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        String s = null;
        s = in.nextLine();
        char ch = in.next().charAt(0);
        int result = 0;
        for(int i = 0;i<s.length();i++){
            char temp = s.charAt(i);
            if(ch == temp )
                result++;
            else if(Character.isLetter(temp)){
                if(Character.toLowerCase(temp) == Character.toLowerCase(ch))
                    result++;
            }
        }
        System.out.println(result);
    }
}